{% extends "forum/base.html" %}
{% comment %}
<!--
  Copyright (C) 2008 ZHENG Zhong <heavyzheng nospam-at gmail D0T com>
  - http://heavyz.blogspot.com/
  - http://buggarden.blogspot.com/

  The forum board page. This page displays a list of threads in the forum board, and a toggle-able
  form to post a new thread.
  
  Created on 2008-05-07.
  $Id: view_board.html 252 2008-10-28 11:06:08Z heavyzheng $
-->
{% endcomment %}

{#------------------------------------------------------------------------------------------------#}

{% block html_head %}

<title>{{ board.name|escape }} :: The Bug Garden Forum</title>

<script type="text/javascript">//<![CDATA[

  function closeMessage() {
    $(".message").hide("slow");
  }
  
  function showPostThreadForm() {
    $("#post-thread .form-toggle").hide();
    $("#post-thread .submitting" ).hide();
    $("#post-thread .form"       ).show("slow");
  }
  
  function hidePostThreadForm() {
    $("#post-thread .form"       ).hide();
    $("#post-thread .submitting" ).hide();
    $("#post-thread .form-toggle").show("slow");
  }
  
  function submitPostThreadForm() {
    $("#post-thread .form"       ).hide();
    $("#post-thread .form-toggle").hide();
    $("#post-thread .submitting" ).show("slow");
    $("#post-thread .form form"  ).submit();
  }

//]]></script>

{% endblock %}{# html_head #}

{#------------------------------------------------------------------------------------------------#}

{% block header %}

<div class="title">{{ board.name|escape }}</div>
<div class="subtitle">{{ board.desc|escape }}</div>

{% endblock %}{# header #}

{#------------------------------------------------------------------------------------------------#}

{% block navbar %}

<img src="/static/forum/images/home_icon.png" alt="Bug Garden Forum"/>
<a href="/forum/">Forum Home</a>
&#187;
<img src="/static/forum/images/board_icon.png" alt="Board"/>
{{ board.name|escape }}
<br/>
Manager(s):
{% for manager in board.managers %}
  <a href="#TODO">{{ manager.nickname }}</a>,
{% endfor %}
{% if board.is_current_user_manager %}
  <a href="/forum/admin_board/{{ board.key.id }}/">
    <img src="/static/forum/images/admin_icon.png" alt="Admin"/>
  </a>
{% endif %}

{% endblock %}{# navbar #}

{#------------------------------------------------------------------------------------------------#}

{% block content %}

{% if error %}
  <div class="error message">
    {{ error }}
    <a href="javascript:void(0);" onclick="closeMessage();">[close]</a>
  </div>
{% endif %}

{% if info %}
  <div class="info message">
    {{ info }}
    <a href="javascript:void(0);" onclick="closeMessage();">[close]</a>
  </div>
{% endif %}


<div id="threads" class="section">

  <table class="bordered" cellspacing="0" width="100%">
  
    <tr class="head-row">
      <td class="nowrap">Threads</td>
      <td class="nowrap" align="center" width="15%">Last Post</td>
      <td class="nowrap" align="center" width="1%">Replies</td>
    </tr>
    
    {% for thread in threads %}
      <tr class="{% cycle odd-row,even-row %}">
        <td>
          {% if thread.is_recommended %}
            <img src="/static/forum/images/recommended_icon.png" alt="Recommended Thread"/>
          {% else %}
            <img src="/static/forum/images/thread_icon.png" alt="Thread"/>
          {% endif %}
          <b><a href="/forum/thread/{{ thread.key.id }}/">{{ thread.title|escape }}</a></b>
          {% if thread.attachment %}
            <img src="/static/forum/images/attachment_icon.png" alt="Attachment"/>
          {% endif %}
          <br/>
          <span class="small">
            Posted by <a href="#TODO">{{ thread.author.nickname }}</a>
            at {{ thread.post_date|date:"Y-m-d h:i:s A" }}
          </span>
        </td>
        <td class="nowrap small" width="15%">
          by <a href="#TODO">{{ thread.last_post_author.nickname }}</a>
          <br/>
          at {{ thread.last_post_date|date:"Y-m-d h:i:s A" }}
        </td>
        <td class="nowrap small" align="center" width="1%">
          {{ thread.replies }}
        </td>
      </tr>
    {% endfor %}
  </table>

</div><!--/#threads-->


<div id="post-thread" class="section">

  <div class="form-toggle">
    <img src="/static/forum/images/post_icon.png" alt="post_icon.png"/>
    <a href="javascript:void(0);" onclick="showPostThreadForm();">Post a new thread</a>
  </div>

  <div class="form hidden">
    {% if user %}
      <form action="/forum/board/{{ board.key.id }}/add_thread/"
            method="POST"
            enctype="multipart/form-data">
        <p>
          <b>Title:</b><br/>
          <input name="title" type="text" size="60"/>
        </p>
        <p>
          <b>Content:</b><br/>
          <textarea name="content" rows="10" cols="100"></textarea>
        </p>
        <p>
          <b>Attachment:</b><br/>
          <input name="attachment" type="file" size="60"/>
        </p>
        <p>
          <input type="submit" value="Post"   onclick="submitPostThreadForm();"/>
          <input type="button" value="Cancel" onclick="hidePostThreadForm();"/>
        </p>
      </form>
    {% else %}
      You are not logged in. To post a new thread, you need to login first.<br/>
      <a href="{{ log_url }}">Login</a>
      or
      <a href="javascript:void(0);" onclick="hidePostThreadForm();">Cancel</a>.              
    {% endif %}
  </div>
  
  <div class="submitting hidden">
    <img src="/static/forum/images/waiting.gif" alt="waiting.gif"/>
    Posting new thread... Please wait...
  </div>

</div><!--/#post-thread-->

{% endblock %}{# content #}



